﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using CapaEntidades;
using CapaNegocio;

namespace SisHotel
{
    public partial class detalleHabitacion : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            double subTotal = 0.0;

            if (!Page.IsPostBack)
            {
                entCliente c = (entCliente)Session["cliente"];
                if (c != null)
                {
                    lblNombre.Text = c.Nombres;
                    lblApellidos.Text = c.Apellidos;
                    lblNroDocumento.Text = c.NroDocumento;
                    lblNacionalidad.Text = c.Nacionalidad.Nombre;
                    lblCorreo.Text = c.Correo;
                    lblTelefono.Text = c.Telefono;
                    DataTable dt = (DataTable)Session["reserva"];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataRow r = dt.Rows[i];
                        subTotal += Convert.ToDouble(r["Precio"]) * Convert.ToInt32(r["NroNoches"]);
                    }
                    lblSubTotal.Text = subTotal.ToString();
                    lblTotal.Text = (((double)Convert.ToInt32(lblSubTotal.Text) * 0.18) + Convert.ToInt32(lblSubTotal.Text)).ToString();
                    entPago p = new entPago();
                    p.Total = Convert.ToDouble(lblTotal.Text);
                    Session["Pago"] = p;
                    gvHabReservadas.DataSource = dt;
                    gvHabReservadas.DataBind();
                }
            }
        }

        protected void btnReservar_Click(object sender, EventArgs e)
        {
            Response.Redirect("datosTarjeta.aspx");
            /*DataTable dt = (DataTable)Session["reserva"];
            entCliente c = (entCliente)Session["cliente"];
            int i = negReserva.Instancia.RegistrarReserva(dt, c);
            Boolean correcto = negEnviarCorreo.Instancia.enviaCorreo(c.Correo);
            if (i > 0 && correcto)
            {
                Response.Write("<script>alert('Reserva Exitosa')</script>");
            }*/
        }
    }
}